package com.example.lulala.case03_16110100428;

import android.content.Intent;
import android.content.SharedPreferences;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class WelcomeActivity extends AppCompatActivity {
    private TextView tv_username,tv_password;
    private Button btn_setting;
    private SharedPreferences sp;
    private SharedPreferences.Editor editor;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_welcome);
        tv_username=findViewById(R.id.tv_username);
        tv_password=findViewById(R.id.tv_password);
        btn_setting=findViewById(R.id.btn_setting);
        tv_username.setText(getIntent().getStringExtra("username"));
        tv_password.setText(getIntent().getStringExtra("password"));

        sp=getSharedPreferences("case03_sp",MODE_PRIVATE);
        editor=sp.edit();
        editor.putString("username",getIntent().getStringExtra("username"));
        editor.commit();
        View.OnClickListener listener=new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent =new Intent(WelcomeActivity.this,activity_setting.class);
                startActivity(intent);
            }
        };
       btn_setting.setOnClickListener(listener);
    }
}
